package ch09;

class _02_EqualsEx2 {
	public static void main(String[] args) {
		Person p1 = new Person(8011081111222L);
		Person p2 = new Person(8011081111222L);

		System.out.println(p1 == p2); // false
		System.out.println(p1.equals(p2)); // true
	}
}

class Person {
	long id;

	public boolean equals(Object obj) {
		if (obj != null && obj instanceof Person)
			return id == ((Person) obj).id;
		else return false;
	}

	Person(long id) {
		this.id = id;
	}
}